package com.jack.mizhe.ui.ui;

import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RadioGroup;

import com.jack.mizhe.R;
import com.jack.mizhe.ui.fragmenthelp.FragmentFactory;

public class MainActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener{
    private RadioGroup radioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
    radioGroup= (RadioGroup) findViewById(R.id.radioGroup_main);
        radioGroup.setOnCheckedChangeListener(this);
        radioGroup.check(R.id.radioButton_today);
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        Fragment fragment= FragmentFactory.createFragment(checkedId);
        getSupportFragmentManager().beginTransaction().replace(R.id.fra,fragment).commit();
    }
}
